Neo Bui's profile

Introduction To Java Script Basic Concepts

     This portfolio will demonstrate about basic concept of JavaScript which are Variable, String, Number, If Statement, The For Loop, Array, Object and Function. Understand These concept will help creating web pages using Javascript and Programming in Java language.

    Reference:
    NodeSchool n.d., Learn the basics of JavaScript, Glitch website, retrieved 19 August 2018, <https://glitch.com/~javascripting>.
      Variable

     Variables are used to store data in computer programming. A variable cab be declared and defined by using some simple method in Java Scripts, the example below shows how to use var to declare a variable which is example then use = to define it to a specific value which is 'some string'.
     String

     String is a sequence of characters, using single or double quotation marks to declare a string, can be used as a type of variable. There are also some JavaScript functions that can define the length of string, or inspect, manipulate the contents of string. These examples below show how to create a string variable, define length of string, revise string.
     Number
 
      Numbers can be integers (1, 25, 367) or floats (3.14, 1.5, 9.654), can be used as a type of variable. JavaScript allows users to do basic math with number using operators like +, -, *, /, and %. For complex math users can use Math function, for example, Math.round() is a function to round the number up. There is also a function .toString() change variable type from number to string. These examples below show how to create a number variable, do complex math with number, turning number to string.
If Statement
     
     If Statements can be used to alter the control flow of a program,  based on a specified boolean (True-False) condition. This example below how to use if statement to print a statement based on the length of the string.
The For Loop

      The For Loop allow user to run a section a code a certain number of time (user decides). Example of The For Loop: for (var i = 0; i<n; i++) { //code section …}. So basically there are 3 part:
- The first part, var i = 0, is run once at the beginning and i is used to track the number of time that the loop has run.
- The second part, i<n (with n is a nature number), is checked at the beginning of the loop, if the statement is true then the code section inside the loop is executed, and the loop will run n times. If it is false, then the loop is complete.
- The final part,i++, it executed at the end of every loop. This by 1 after each loop. Once I reaches n, the loop is complete.
     This example below shows how the For Loop work.


Array

     Array is a list of values, can be used as a type of variable. Array can be filtered by using .filter() method, it also can be accessed through an index number with the Index numbers start from 0 to the array's length minus one. These example below show the example of an array, how to filter even numbers from an array of number, and how to access elements of an array.
      Also access and manipulate all the values of an array can be done easier by using The For Loop. The example below show how to access all the elements of pets array and add a word at the end of each elements.
Object
 
     Objects are lists of values that are defined by keys instead of integers like arrays. Object properties can also be accessed and manipulated by using a method. These example below show an example of an object, and how to access properties of an object.

Function

      Functions are made by a section of code, it can take input and then processes that input to produce output. The example below show how to create a function that add text to a input string.    
     Another example of function that takes three arguments and then to some calculations using them.
Introduction To Java Script Basic Concepts
Published:

Introduction To Java Script Basic Concepts

Published: